{% extends "static/view/template.html" %}
{% block body %}

<style>
.glyphicon:hover {
    background-color: #ffff00;
    cursor: pointer;
}

table {
  width: 80%;
  border: 2px solid #C63D0F;
  border-radius: 3px;
  background-color: #fff;
}

th {
  background-color: #C63D0F;
  color:  #fff;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -user-select: none;
}

td {
  background-color: #f9f9f9;
  word-wrap:break-word;
}

th, td {
  max-width: 120px;
  padding: 10px 20px;
}

</style>
<div id="app">
    <div class="container">
        <div class="page-header">
        </div>

        <div class="page-header">
            <h1> <font color= #333333><center>Service List</center></font>
                <small><center><font color= #778899></font></center></small>
            </h1>
        </div>
    </div>
    
    <div class="row">
        <div class="col-xs-1"></div>
        <div class="col-xs-10">
            <h3 v-if="filterKey!=''">
                Filtered By: {{filterKey}} &nbsp<span class="glyphicon glyphicon-remove" style="font-size: 0.75em;" onclick="window.location.href = 'service_meta.html';"></span>
            </h3>
        </div>
        <div class="col-xs-1"></div>
    </div>
    <div class="row">
        <div class="col-xs-1"></div>
        <div class="col-xs-10"> 
            <table class="table table-striped">
                <thead>
                    <tr><th>ID</th><th>Name</th><th>Package</th><th>Status</th><th>Del</th><th>GPID</th><th>Ballot</th><th>Membership</th></tr>
                </thead>
                <tbody v-for="(app_index, app) in appInfo.infos" >
                    <tr>
                        <td rowspan="{{get_app(app.app_id).partitions.length + 1}}">{{app.app_id}}</td>
                        <td rowspan="{{get_app(app.app_id).partitions.length + 1}}">{{app.app_name}}</td>
                        <td rowspan="{{get_app(app.app_id).partitions.length + 1}}">{{app.app_type}}</td>                        
                        <td rowspan="{{get_app(app.app_id).partitions.length + 1}}">{{AS_STATES[app.status]}}({{app.status}})</td>
                        <td v-if="app.status < AS_DROPPING" rowspan="{{get_app(app.app_id).partitions.length + 1}}"><span class="glyphicon glyphicon-remove" @click="del(app.app_name)"></td>
                        <td v-else rowspan="{{get_app(app.app_id).partitions.length + 1}}"> - </td>
                        <td v-if="get_app(app.app_id).partitions.length > 0" colspan=3 style="display:none;"> &nbsp; </td>
                        <td v-else colspan=3> &nbsp; </td>
                    </tr>
                    <tr v-for="pidx in (get_app(app.app_id).partitions.length)">
                        <td>{{get_app(app.app_id).partitions[pidx].pid.toString()}}</td>
                        <td>{{get_app(app.app_id).partitions[pidx].ballot}}</td>
                        <td>{{get_app(app.app_id).partitions[pidx].membership}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="col-xs-1"></div>
    </div>

    <div id="info-modal" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Info</h4>
          </div>
          <div class="modal-body">
              {{info}}
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>

</div>

<!--<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.min.js"></script>-->
<script src="js/vue.js"></script>
<script src="js/service_meta.js"></script>

{% endblock %}

